<form action="{:sysuri()}" method="post" data-auto="true" class="layui-form layui-card" id="RebateForm" data-table-id="RebateConfigTable">
    <div class="layui-card-body ta-pl-40">

        <div class="layui-row layui-form-item layui-col-space10">
            <div class="layui-col-xs3">
                <span class="help-label label-required-prev"><b>奖励类型</b>Type</span>
                <select class="layui-select" name="type">
                    {foreach $prizes as $k=>$v}{if isset($vo.type) and $vo.type eq $k}
                    <option value="{$k}" selected>{$v}</option>
                    {else}
                    <option value="{$k}">{$v}</option>
                    {/if}{/foreach}
                </select>
            </div>
            <label class="layui-col-xs9 block relative">
                <span class="help-label"><b>奖励名称</b>Reward Name</span>
                <input class="layui-input" name="name" placeholder="请输入奖励名称" required value="{$vo.name|default=''}">
            </label>
            <label class="layui-col-xs3 block relative">
                <span class="help-label"><b>规则编号</b>Code</span>
                <input class="layui-input layui-bg-gray" name="code" readonly required value="{$vo.code|default=''}">
            </label>
            <div class="layui-col-xs9">
                <span class="help-label label-required-prev"><b>结算方式</b>Settlement type</span>
                {empty name='vo.stype'}{assign name='vo.stype' value='0'}{/empty}
                <div class="layui-input flex flex-align-center">
                    {foreach ['支付后立即结算','确认收货后结算'] as $k => $v}
                    {if isset($vo.stype) and $vo.stype eq $k}
                    <input name="stype" type="radio" value="{$k}" title="{$v}" checked>
                    {else}
                    <input name="stype" type="radio" value="{$k}" title="{$v}">
                    {/if}{/foreach}
                </div>
            </div>
        </div>

        <div class="hr-line-dashed"></div>
        {foreach [3,2,1] as $k}
        {php} $lname = "p".$k."_level"; {/php}
        {php} $ltype = "p".$k."_reward_type"; {/php}
        {php} $lnumber = "p".$k."_reward_number"; {/php}
        {php} $vo[$lname]=$vo[$lname]??0; {/php}
        <div class="layui-row layui-col-space10">
            <div class="layui-col-xs2 ">
                <span class="help-label label-required-prev"><b>上 {$k} 级代理</b></span>
                <select class="layui-select" name="{$lname}">
                    {foreach $levels as $level}{if isset($vo[$lname]) and $vo[$lname] eq $level.number}
                    <option value="{$level.number}" selected>{$level.name}</option>
                    {else}
                    <option value="{$level.number}">{$level.name}</option>
                    {/if}{/foreach}
                </select>
            </div>
            <div class="layui-col-xs8">
                <span class="help-label label-required-prev"><b>计算类型</b>类型为比例时奖励系数为百分比</span>
                {php}$vo[$ltype]=$vo[$ltype]??0;{/php}
                <div class="layui-input flex flex-align-center">
                    {foreach ['固定金额 / 单','交易比例 / 单','利润比例 / 单'] as $k=>$v}
                    {if isset($vo[$ltype]) and $vo[$ltype] eq $k}
                    <input name="{$ltype}" type="radio" value="{$k}" title="{$v}" checked>
                    {else}
                    <input name="{$ltype}" type="radio" value="{$k}" title="{$v}">
                    {/if}{/foreach}
                </div>
            </div>
            <label class="layui-col-xs2 block relative">
                <span class="help-label label-required-prev"><b>奖励系数</b></span>
                <input class="layui-input" name="{$lnumber}" lay-affix="number" min="0" step="0.0001" placeholder="请输入奖励系数" required value="{$vo[$lnumber]|default='0'}">
            </label>
        </div>
        {/foreach}
        {php} $lname = "p0_level"; {/php}
        {php} $ltype = "p0_reward_type"; {/php}
        {php} $lnumber = "p0_reward_number"; {/php}
        <div class="layui-row layui-col-space10">
            <div class="layui-col-xs2 layui-form-item">
                <span class="help-label label-required-prev"><b>用户奖励</b></span>
                <select class="layui-select" name="{$lname}">
                    {foreach $levels as $level}{if $level.number>-2}
                    {if isset($vo[$lname]) and $vo[$lname] eq $level.number}
                    <option value="{$level.number}" selected>{$level.name}</option>
                    {else}
                    <option value="{$level.number}">{$level.name}</option>
                    {/if}{/if}{/foreach}
                </select>
            </div>
            <div class="layui-col-xs8">
                <span class="help-label label-required-prev"><b>计算类型</b>类型为比例时奖励系数为百分比</span>
                {php} $vo[$ltype]=$vo[$ltype]??0; {/php}
                <div class="layui-input flex flex-align-center">
                    {foreach ['固定金额 / 单','交易比例 / 单','利润比例 / 单'] as $k=>$v}
                    {if isset($vo[$ltype]) and $vo[$ltype] eq $k}
                    <input name="{$ltype}" type="radio" value="{$k}" title="{$v}" checked>
                    {else}
                    <input name="{$ltype}" type="radio" value="{$k}" title="{$v}">
                    {/if}{/foreach}
                </div>
            </div>
            <label class="layui-col-xs2 block relative">
                <span class="help-label label-required-prev"><b>奖励系数</b></span>
                <input class="layui-input" name="{$lnumber}" lay-affix="number" min="0" step="0.0001" placeholder="请输入奖励系数" required value="{$vo[$lnumber]|default='0'}">
            </label>
        </div>

        <div class="layui-hide">
            <div class="hr-line-dashed"></div>
            <label class="layui-form-item block relative">
                <span class="help-label"><b>内部备注</b>Remark</span>
                <textarea class="layui-textarea" name="remark" placeholder="请输入内部备注">{$vo.remark|default=''}</textarea>
            </label>
        </div>

        <div class="hr-line-dashed"></div>
        {notempty name='vo.id'}<input name='id' type='hidden' value='{$vo.id}'>{/notempty}

        <div class="layui-form-item text-center">
            <button class="layui-btn" type='submit'>保存数据</button>
            <button class="layui-btn layui-btn-danger" data-close data-confirm="确定要取消编辑吗？" type='button'>取消编辑</button>
        </div>
    </div>

</form>

<script>
    $(function () {
        $('#RebateForm').parents('.layui-layer-content').css({overflow: 'unset'});
    });
</script>